// This is the main.js file. Import global CSS and scripts here.
// The Client API can be used here. Learn more: gridsome.org/docs/client-api

import DefaultLayout from '~/layouts/Default.vue'
import ElementUI from 'element-ui';
import mavonEditor from 'mavon-editor';
import util from './utils/index';

import 'mavon-editor/dist/css/index.css';
import 'mavon-editor/dist/markdown/github-markdown.min.css';
import './assets/index.css';
import 'element-ui/lib/theme-chalk/index.css';

export default function (Vue, { router, head, isClient }) {
  // Set default layout as a global component
  Vue.use(ElementUI);
  Vue.use(mavonEditor);
  // 添加全局解析markdown的方法
  Vue.prototype.$markdown = (value) => {
    return mavonEditor.markdownIt.render(value)
  };
  // 添加全局filter处理时间
  Vue.filter('date', (value, format = 'YYYY-MM-DD') => {
    return dayjs(value).format(format);
  });
  // 添加全局算法
  Vue.prototype.$util = util;
  Vue.component('Layout', DefaultLayout);

}
